package logging;

import Exception.InvalidLevelException;
import Filter.FilterStrategy;

public class FilterCustom2 implements FilterStrategy{
	
    private String msgFilter;
    private Level levelFilter;
    
    
    public FilterCustom2 (String msg, String level) {              
    	
        try{
        	this.msgFilter=msg;
            this.levelFilter =  Level.stringToLevel(level);
        }catch (InvalidLevelException e) {
        		e.printStackTrace();
        }       
    } 
    
    public Level getLevel() {
        return this.levelFilter;
    }

    public boolean apply(Record record) {           
            return ((record.getMessageFormatted().indexOf(this.msgFilter) >= 0)&&(this.getLevel().getPriority() <= record.getLevel().getPriority()));
    }   
    
}
